<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #ad {
            width: 300px;
            height: 300px;
            background-color: antiquewhite;
            /*绝对定位放置到浏览器右下角，即使有下拉条时广告弹窗也不会改变位置*/
            position: fixed;
            bottom: 0px;
            right: 0px;
            /*display: none;*/
        }
    </style>
    <script>
        function init() {
            setTimeout(showAd, 2000)
        }

        function showAd() {
            var ad = document.getElementById("ad");
            ad.style.display = "block";
        }
        function closeAd(){
                var ad = document.getElementById("ad");
                ad.style.display ="none";
            }
    </script>
</head>

<body onload="init()">
    <div id="ad">
        <button onclick="closeAd()">关闭</button>
    </div>
</body>

</html>